<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="Stylesheet" type="text/css" href="doc.css" />
<title>EMF Model Query Overview</title>
</head>
<body>
<h1><a name="top">EMF Model Query Overview</a></h1>
<p>
The query framework defined in the <em class="CodeName">org.eclipse.emf.query</em>
plug-in provides an infrastructure for specifying and executing
queries against a set of EMF model elements and their contents. The following are the
main classes to be used when formulating query statements:
</p>
<ol>
	<li>
	The <code>IEObjectSource</code> interface defines the search scope of
	elements to be used in a query.
	</li>
	<li>
	The <code>SELECT</code> class implements a template-function that does the
	iteration over model elements and applies the search condition on each; it
	collects the resulting elements into an <code>IQueryResult</code> object
	and returns it to the caller.
	</li>
	<li>
	The <code>FROM</code> class represents the elements to search. It is
	responsible of providing an appropriate iterator for the elements in the
	search space.
	</li>
	<li>
	The <code>WHERE</code> class applies the search conditions over the elements
	in the search set.
	</li>
	<li>
	The <code>UPDATE</code> class passes the elements who satisfy the search
	condition to a caller-supplied modification function. It collects the
	modified elements into a query result object and returns it to the caller.
	</li>
	<li>
	The <code>IQueryResult</code> interface provides the set of elements
	retrieved by a query.
	</li>
	<li>
	The <code>EObjectCondition</code> class is the abstract parent of all
	conditions that deal with model-elements (i.e., EObjects). It incorporates
	the services of a PruneHandler in order to answers whether or not to prune
	the element tree at a specific element and thus ignore its children.
	</li> 
	<li>
	The <code>ConditionPolicy</code> class is used to allow the user to decide
	how to apply a given condition on a multi-valued structural features of
	model elements. It supports both the: exists (ANY) and for-all (ALL)
	quantifier semantics.
	</li>
	<li>
	The <code>EObjectStructuralFeatureValueCondition</code> class is the parent
	class for conditions that are check the values stored in model elements'
	features. It uses the help of two other condition objects. The first is an
	EObjectCondition that is used to decide on the validity of the context
	element (a context element is the model element whose attribute we are
	evaluating) and the other condition is an evaluator Condition that it uses
	to evaluate the value held in the feature and whether or not it matches
	what the user is looking for.
	</li>
	<li>
	The <em class="CodeName">org.eclipse.emf.query.ocl</em> plug-in provides OCL
	extensions to the EMF Model Query framework.  It defines the
	<code>BooleanOCLCondition</code> class for specifying query conditions using
	OCL constraints.
	</li>
</ol>
<p>
Using the above classes follow the steps outlined below to create and execute
queries.
</p>
<ol>
	<li>
	Create an implementation of the <code>IEObjectSource</code> interface.
	</li>
	<li>
	Extend the <code>EObjectCondition</code> class to define custom conditions
	or use one of the pre-defined conditions available as in the query framework.
	</li>
	<li>
	Create a statement using the <code>SELECT</code> or <code>UPDATE</code> clause.
	</li>
	<li>
	Execute the statement to produce the results.
	</li>
	<li>
	Check to ensure that the query did not generate any exceptions during its
	execution.
	</li>
</ol>
<p>
Please refer to the tutorial <a href="../../tutorials/queryTutorial.html">Query Framework Tutorial</a> 
and <a href="../../tutorials/oclQueryTutorial.html">OCL Query Tutorial</a> for reviewing some code samples.
</p>

<hr/>

<p>
<a href="http://www.eclipse.org/legal/epl-v10.html">Copyright (c) 2000, 2007 IBM Corporation and others. All Rights Reserved.</a>
</p>
</body>
</html>
